﻿/**
 * Scene
 * 
 * @version 2011.12.16
 * @author  Bruno Miguel de Oliveira Tamer <bmotamer@gmail.com>
 */

namespace Main.src.scene
{

    /// <summary>
    /// Controlador de cena
    /// </summary>
    public static class Scene
    {

        #region Class Variables

        /// <summary>
        /// Cena atual
        /// </summary>
        private static Scene_Base _Current;

        #endregion

        #region Get / Set Current

        /// <summary>
        /// Cena atual
        /// </summary>
        public static Scene_Base Current
        {
            get
            {
                return _Current;
            }
            set
            {
                Set(value);
            }
        }

        #endregion

        #region Transition

        /// <summary>
        /// Muda a cena atual
        /// </summary>
        /// <param name="newScene">Nova cena</param>
        public static void Set(Scene_Base newScene)
        {
            if (_Current != null)
                _Current.Terminate();
            _Current = newScene;
            if (_Current != null)
                _Current.Start();
        }

        #endregion

        #region Update

        /// <summary>
        /// Atualiza a cena atual
        /// </summary>
        /// <returns>Se a cena atual não for null</returns>
        public static bool Update()
        {
            if (_Current == null)
                return false;
            _Current.Update();
            return true;
        }

        #endregion

    }

}